<template>
  <tbody>
    <tr v-for="(item, index) in goodList" :key="index">
      <td>
        <input type="checkbox" v-model="item.checked" />
      </td>
      <td>{{ item.name }}</td>
      <td>{{ item.price }}</td>
      <td>
        <button :disabled="item.num === 1" @click="redBtn(index)">-</button
        >{{ item.num }}<button @click="addBtn(index)">+</button>
      </td>
      <td>{{ item.price * item.num }}</td>
      <td><button @click="delBtn(index)">删除</button></td>
    </tr>
  </tbody>
</template>

<script>
import { mapMutations,mapState} from 'vuex'
export default {
  computed: {
    ...mapState(['goodList']),
  },
  methods: {
    ...mapMutations(['addNum','redNum','Delete']),
    addBtn(index) {
      this.addNum(index)
    },
    delBtn(index){
      this.Delete(index)
    },
    redBtn(index){
      this.redNum(index)
    }
  },
}
</script>

<style></style>
